<?

function _app_iface_head_begin ($container) {

	global $_APP_SESSION_USER;
	global $_GLOBAL_DBH;

	$company_id = $_APP_SESSION_USER->company_id ? $_APP_SESSION_USER->company_id : "1";

	/* get trash bin item count */
	if ($trash_bin = $_GLOBAL_DBH->query ("SELECT COUNT(*) AS total FROM trash_bin WHERE user_id={$_APP_SESSION_USER->id}")) {

		if ($trash_bin = $_GLOBAL_DBH->fetch_object ($trash_bin)) {

			$vmc_trash_bin = ($trash_bin->total > 0) ?
					"vmc_mainheader_trash_full" :
					"vmc_mainheader_trash_empty";
			$trash_items = $trash_bin->total ? "&nbsp;({$trash_bin->total} items)" : null;
		} else $vmc_trash_bin = "vmc_mainheader_trash_empty";
	} else $vmc_trash_bin = "vmc_mainheader_trash_empty";

	/* begin get timesheet information */
	if ($timesheet = $_GLOBAL_DBH->query ("SELECT * FROM timesheet WHERE user_id={$_APP_SESSION_USER->id} AND date_begin AND date_end=''")) {

		if ($_GLOBAL_DBH->num_rows ($timesheet)) {

			$timesheet = $_GLOBAL_DBH->fetch_object ($timesheet);
			$time_href = "/admin/users/timesheet/?timesheet=out&timesheet_id={$timesheet->id}";
			$time_class = "vmc_mainheader_timesheet_out";
			$time_label = "Clock-Out";
		} else {

			$time_href = "/admin/users/timesheet/?timesheet=in";
			$time_class = "vmc_mainheader_timesheet_in";
			$time_label = "Clock-In";
		}
	} else {

		$time_href = "/admin/users/timesheet/?timesheet=in";
		$time_class = "vmc_mainheader_timesheet_in";
		$time_label = "Clock-In";
	}


	print <<<HTML

<div class="vmc_header">
	<div class="vmc_header_wrapper">
		<div class="vmc_header_logo"></div>
		<div class="vmc_header_tabbing">
			<ul>
				<li><a href="?panel=ecm_aw_panel"><div id="my_workshop">My Workshop</div></a></li>

				<li><a href="?panel=ecm_so_panel"><div id="address_book">Address Book</div></a></li>
				<li><a href="?panel=ecm_as_panel"><div id="account_settings">Account Profile</div></a></li>
			</ul>
		</div><!-- end vmc_header_tabbing -->
	</div><!-- end vmc_header_wrapper -->


HTML;
}

function _app_iface_head_end ($container) {

	print <<<HTML

</div><!-- end vmc_header -->

HTML;
	include ("popup_window.php");
}
function _app_iface_head_navigation ($container) {

	print <<<HTML
	<div class="vmc_navigation_tools">
		<ul>
			<li id="link_inventory_control"><a href=""><div>Inventory Control</div></a></li>
			<li id="link_event_management"><a href=""><div>Event Management</div></a></li>
			<li id="link_asset_tracking"><a href=""><div>Asset Tracking</div></a></li>
			<li id="link_expense_reports"><a href=""><div>Expense Reports</div></a></li>
			<li id="link_order_management"><a href=""><div>Order Management</div></a></li>
			<li id="link_work_orders"><a href=""><div>Work Orders</div></a></li>
			<li id="link_resource_manager"><a href=""><div>Resource Manager</div></a></li>
			<li id="link_service_scheduling"><a href=""><div>Service Scheduling</div></a></li>
			<li id="link_accounting_ledger"><a href=""><div>Accounting Ledger</div></a></li>
		</ul>
	</div><!-- end vmc_navigation_tools -->
HTML;
}


function _app_iface_begin ($container) {
	print <<<HTML

<div class="vmc_body">
	<div class="vmc_content">

HTML;
}

function _app_iface_end ($container) {

	print <<<HTML

	</div><!-- end vmc_content -->
</div><!-- end vmc_body -->

HTML;
}

function _app_iface_foot_begin ($container) {

	print <<<HTML

<div class="vmc_footer">
	<div class="vmc_footer_wrapper">
		<div class="vmc_footer_options">
			<div class="vmc_footer_panel_options">
				
				<div id="vmc_footer_option_alerts" class="vmc_footer_panel_option" onclick="javascript: toggle_panel ('vmc_footer_panel_control');"></div>
				<div id="vmc_footer_option_current" class="vmc_footer_panel_option" onclick="javascript: toggle_panel ('vmc_footer_panel_control');"></div>
				<div id="vmc_footer_option_tasks" class="vmc_footer_panel_option" onclick="javascript: toggle_panel ('vmc_footer_panel_control');"></div>
				<div id="vmc_footer_option_search" class="vmc_footer_panel_option" onclick="javascript: toggle_panel ('vmc_footer_panel_control');"></div>
			</div>
			<div class="vmc_footer_panel_toggle" onclick="javascript: toggle_panel ('vmc_footer_panel_control');"></div>
		</div><!-- end vmc_footer_options -->
		<div id="vmc_footer_panel_control" hidden="true" class="vmc_footer_panel">
HTML;
			include ("test_file.php");
	print <<<HTML

		</div>
	</div><!-- end vmc_footer_wrapper -->
</div><!-- end vmc_footer -->

HTML;
}

function _app_iface_foot_end ($container) {

	print <<<HTML

HTML;
}

function _app_load_iface_begin ($container) {

	global $_APP_SESSION_USER;

	if (isset ($_SESSION["_APP_SESSION"])) {

		$styles = isset ($_REQUEST["theme"]) ? $_REQUEST["theme"] : ($_APP_SESSION_USER->theme ? $_APP_SESSION_USER->theme : "default");
	} else $styles = "default";

	print <<<HTML
<!!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<link href="/css/vmc_main.css" rel="stylesheet" type="text/css"></link>
	<script language="JavaScript" src="/js/jquery-1.2.1.js"></script>
	<script language="JavaScript" src="/js/common.js"></script>
</head>
<body>

HTML;

}

/* function _app_create_panel_details () {

	$_OBJECT_IFACE_PANEL = new Container ();
	$_OBJECT_IFACE_PANEL->set_callback_begin ("_app_panel_details");
	$_OBJECT_IFACE_PANEL->set_option ("callback_end", false);

	return null;//$_OBJECT_IFACE_PANEL;
}

function _app_panel_details ($container) {

	global $_GLOBAL_DBH;
	global $_APP_SESSION_USER;

	$panel_label = (($label = $container->get_variable ("label")) ? $label : "Current Navigation Panel Options");

	print <<<HTML

	<div class="vmc_document_context"><div class="vmc_border_left"><div class="vmc_border_right"><div class="vmc_document_context_body">
        <div class="vmc_panel_a">
                <div class="vmc_panel_a_header">
			<div class="vmc_panel_tab_border"><div class="vmc_panel_a_tab"><div class="vmc_panel_a_tab_left"><div class="vmc_panel_a_tab_right"><div class="vmc_panel_a_label">{$panel_label}</div></div></div></div></div>
                </div>

                <div class="vmc_panel_a_subheader">
			<ul class="vmc_panel_subheader_menu">
HTML;

	if (isset ($_REQUEST["project_id"])) {

		if ($query = $_GLOBAL_DBH->query ("SELECT title FROM projects WHERE id={$_REQUEST["project_id"]}")) {

			$project = $_GLOBAL_DBH->fetch_object ($query);
			$project->title = strlen ($project->title) > 16 ? substr ($project->title, 0, 13) . "..." : $project->title;
		}

		print <<<HTML
				<li class="vmc_subheader_project_title"><a class="vmc_subheader_link_title" href="/admin/projects/projects/fs_projects.php?fs_action=view&fs_tab=main&project_id={$_REQUEST["project_id"]}">Project :: {$project->title}</a></li>
				<li class="vmc_subheader_task"><a class="vmc_subheader_link" href="/admin/projects/projects/fs_projects.php?fs_action=addnew&fs_tab=tasks&fs_tab_option=fs_tasks&project_id={$_REQUEST["project_id"]}">Create A Task</a></li>
HTML;
	}
	
	if (isset ($_REQUEST["task_id"])) {

		$task_id = isset ($_REQUEST["parent_id"]) ? $_REQUEST["parent_id"] : $_REQUEST["task_id"];

		if ($query = $_GLOBAL_DBH->query ("SELECT title FROM project_tasks WHERE id={$_REQUEST["task_id"]}")) {

			$task = $_GLOBAL_DBH->fetch_object ($query);
			$task->title = strlen ($task->title) > 20 ? substr ($task->title, 0, 17) . "..." : $task->title;
		}

		print <<<HTML
				<li class="vmc_subheader_task_title"><a class="vmc_subheader_link_title" href="/admin/projects/projects/fs_projects.php?fs_tab=tasks&project_id={$_REQUEST["project_id"]}&fs_tab_option=fs_tasks&task_id={$task_id}">Current Task :: {$task->title}</a></li>
HTML;
	}

	if (isset ($_REQUEST["task_id"])) {

		print <<<HTML
				<li class="vmc_subheader_note"><a class="vmc_subheader_link" href="/admin/projects/projects/fs_projects.php?fs_sub_tab_option=fs_task_tasks&fs_sub_action=addnew&fs_action=view&fs_tab=tasks&fs_tab_option=fs_tasks&fs_task_tabs=tasks&fs_sub_action=addnew&project_id={$_REQUEST["project_id"]}&task_id={$_REQUEST["task_id"]}">Create A Task Note</a></li>
				<li class="vmc_subheader_task"><a class="vmc_subheader_link" href="/admin/projects/projects/fs_projects.php?fs_action=addnew&fs_tab=tasks&fs_tab_option=fs_tasks&project_id={$_REQUEST["project_id"]}">Create A Sub Task</a></li>
HTML;
	} elseif (isset ($_REQUEST["project_id"])) {

		print <<<HTML
				<li class="vmc_subheader_note"><a class="vmc_subheader_link" href="/admin/projects/projects/fs_projects.php?fs_action=addnew&fs_tab=notes&fs_tab_option=fs_notes&project_id={$_REQUEST["project_id"]}">Create A Project Note</a></li>
HTML;
	}

	print <<<HTML
				<li class="vmc_subheader_project_title"><a class="vmc_subheader_link" href="/admin/projects/projects/fs_projects.php?fs_action=addnew">Create A Project</a></li>
			</ul>
                        <!-- Data That Should Go Here -->
                </div>
        </div>

        </div></div></div></div>

        <div class="vmc_document_divider"><div class="vmc_border_bottom"><div class="vmc_border_left"><div class="vmc_border_right">
                <div class="vmc_document_idivider"><img src="/admin/img/collab/divider.gif"></div>
        </div></div></div></div>

HTML;
} */

function _app_load_iface_end ($container) {

	print <<<HTML
</body>
</html>

HTML;
}

function _app_create_iface_panel () {

	global $_OBJECT_IFACE_DETAILS;
	//$_OBJECT_IFACE_DETAILS->set_variable ("label", $title);

	$_OBJECT_IFACE_PANEL = new Container ();
	$_OBJECT_IFACE_PANEL->set_callback_begin ("_app_iface_panel_begin");
	$_OBJECT_IFACE_PANEL->set_callback_end ("_app_iface_panel_end");

	return $_OBJECT_IFACE_PANEL;
}

/* function _app_create_context_panel () {

	$_OBJECT_IFACE_PANEL = new Container ();
	$_OBJECT_IFACE_PANEL->set_callback_begin ("_app_iface_context_begin");
	$_OBJECT_IFACE_PANEL->set_callback_end ("_app_iface_context_end");

	return $_OBJECT_IFACE_PANEL;
}

function _app_iface_context_begin () {

	print <<<HTML


        <div class="vmc_document_context"><div class="vmc_border_left"><div class="vmc_border_right">

	<div class="vmc_iface_messaging">
HTML;
}

function _app_iface_context_end () {

	print <<<HTML
	</div>

	</div></div></div>

HTML;
} */

function _app_iface_panel_begin ($container) {

	print <<<HTML

        <!-- open iborder -->
	<div class="vmc_iborder">

        <!-- open iborder outline -->
        <div class="vmc_iborder_top"><div class="vmc_iborder_bottom"><div class="vmc_iborder_left"><div class="vmc_iborder_right">    

        <!-- open iborder corners -->
        <div class="vmc_iborder_top_left"><div class="vmc_iborder_top_right"><div class="vmc_iborder_bottom_left"><div class="vmc_iborder_bottom_right">

	<div class="vmc_sborder"><!-- vmc_sborder_open -->

HTML;
}

function _app_iface_panel_end ($container) {

	print <<<HTML

	</div><!-- vmc_sborder_close -->

        <!-- close iborder corners -->
        </div></div></div></div>

        <!-- close iborder outline -->
        </div></div></div></div>

        <!-- open iborder -->
	</div>
<br>

HTML;
}

function _app_select_query ($params, $columns) {

	global $_GLOBAL_DBH;
	$query = $_GLOBAL_DBH->query ($params);
	$result = array ();

	while ($row = $_GLOBAL_DBH->fetch_object ($query)) {

		array_push ($result, array (
				$columns["key"]=>$row->$columns["key"],
				$columns["value"]=>$row->$columns["value"]));
	}

	return $result;
}

function _app_session_login ($container) {

	print <<<HTML
        <div class="vmc_document_context"><div class="vmc_border_left"><div class="vmc_border_right">

<form action="index.php" method="post">
		<div class="vmc_site_access">User ID: <input class="vmc_fieldset_input" type="input" value="{$_REQUEST["user_name"]}" size="10" name="user_name"></div>
		<div class="vmc_site_access">Password: <input class="vmc_fieldset_input" type="password" value="{$_REQUEST["user_password"]}" size="10" name="user_password"></div>
		<div class="vmc_site_access"><input class="vmc_fieldset_input" type="submit" value="Log-In"></div>
		<a class="vmc_site_access_link" href="new_account.php">&gt; Create An Account</a>&nbsp;:::&nbsp;<a class="vmc_site_access_link" href="get_password.php">&gt;Forgot My Password</a>

</form>
	</div></div></div>
        <div class="vmc_document_divider"><div class="vmc_border_left"><div class="vmc_border_right">
                <div class="vmc_document_idivider"><img src="/admin/img/collab/divider.gif"></div>
        </div></div></div>

HTML;
}

function _app_session_logout ($container) {

	print <<<HTML
        <div class="vmc_document_context"><div class="vmc_border_left"><div class="vmc_border_right">
		{$_SESSION["_APP_SESSION_USER"]->first}&nbsp;{$_SESSION["_APP_SESSION_USER"]->last} with {$_SESSION["_APP_SESSION_USER"]->realm} Rights&nbsp;<a class="vmc_site_access_link" href="index.php?session_logout=true">&gt; Log-Out</a>
	</div></div></div>
        <div class="vmc_document_divider"><div class="vmc_border_left"><div class="vmc_border_right">
                <div class="vmc_document_idivider"><img src="/admin/img/collab/divider.gif"></div>
        </div></div></div>

HTML;
}

?>
